package com.wswy.wzcx.ui.component

import android.graphics.Color
import android.graphics.drawable.ShapeDrawable
import android.graphics.drawable.shapes.OvalShape
import android.support.v4.content.ContextCompat
import android.view.Gravity
import android.view.ViewGroup
import android.widget.TextView
import com.wswy.wzcx.R
import com.wswy.wzcx.model.license.UserCarInfo
import com.wswy.wzcx.widget.home.RubbishFrameLayout

/**
 * Created by wangduheng26 on 2018/4/3.
 * wangduheng26@gmail.com
 */
class WZDBComponent(parent: ViewGroup) : DataBindingComponent<UserCarInfo>(parent, R.layout.wzdb_item_layout) {
    var tvLabel: TextView = view.findViewById(R.id.label1)

    var tvLabel2: TextView = view.findViewById(R.id.label2)
    var tvNumber: TextView = view.findViewById(R.id.tv_number)
    var tvMark: TextView = view.findViewById(R.id.tv_mark)
    var tvMuch: TextView = view.findViewById(R.id.tv_much)
    var rubbishFrame:RubbishFrameLayout=view.findViewById(R.id.rubbish_Layout)
    init {
//        rubbishFrame.changeType(RubbishFrameLayout.TYPE_JZCF)
        tvLabel.gravity = Gravity.CENTER
        tvLabel.setTextColor(Color.WHITE)
        val drawable1 = ShapeDrawable(OvalShape())
        drawable1.paint.color = ContextCompat.getColor(parent.context, R.color.colorAccent)
        tvLabel.background = drawable1
    }

    override fun bind(data: UserCarInfo?) {
        super.bind(data)
        if (data == null) return
        val provincePrefix = data.carNo.substring(0, 1)
        tvLabel.text = provincePrefix
        tvNumber.text = data.trafficCount.toString()
        tvMark.text = data.totalScore.toString()
        tvMuch.text = data.totalFee.toString()
        tvLabel2.text = data.carNo
    }
}